using System;
using System.Windows.Data;

namespace ibba.src.noriskbo.code.converter
{
    public class FormatCnpjCpfConverter: IValueConverter
    {

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (parameter != null)
                {
                    if (parameter.ToString() == "F")
                        return (System.Convert.ToDouble(value).ToString(@"000\.000\.000\-00"));
                }

                return (System.Convert.ToDouble(value).ToString(@"000\.000\.000\/0000\-00"));
            }
            catch (Exception)
            {
                return value;
            }
            
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }

        #endregion
    }
}
